|
|
> Seriously. SL uses these dang things for their rotation matrix,
> apparently due to how the GPU uses them too,
No, the GPU uses standard 4x4 transformation matrices. Somewhere in the
software the conversion must be made from quaternion to matrix to send to
the GPU. SL probably does this though, as I assume it handles the
interpolation between chunks of data.
> also apparently do to it
> being "easier" somehow for the 3D software to work with them.
The good things about quaternions is that it's really easy to interpolate
between two orientations, it's very easy to check that a quaternion
represents a valid orientation, and that it is easy to construct one that
rotates about a vector. All of these are really hard to do if you are
dealing with matricies.
> 3. What happens to the object has to be either 100% accurate to the
> direction the camera is looking, *or* limits need to be applied, so it
> only rotates as much as 45 degrees up/down, never does so in terms of
> where its top and bottom are (i.e., if its "forward" direction is Y, it
> should **never** rotate on the Y axis at all.), and it should be able to
> rotate 360 degrees the other way.
>
> Problem is, how the frack do you transpose the vectors for X,Y,Z to
> something "valid" for an object using this system, without converting it
> to euler values?
If I understand correctly, you are trying to set the orientation of an
object based on the camera position (so it appears to rotate in world space
as the camera moves), but with some limits etc, and return to SL a
quaternion that represents this orientation.
Does SL provide you with functions to help with creating and manipulating
quaternions? That would make your life much easier, if not you'll need to
read up on how to create quaternions for basic things like rotation about an
axis, combining rotations etc.
If you want to limit the rotations somehow, then I think you'll have to work
them out as rotations about the X Y and Z axis first, limit them, then
convert to a quaternion. I don't see any other way.
You should be able to work out the rotations about each axis that allow the
object to point directly to the camera using simple trig functions.
Probably just a pitch rotation about the left/right axis followed by a yaw
rotation about the "up" axis.
Once you have them, limit them in any way you see fit, then convert those
two rotations to quaternion form and multiply them!
To create a quaternion that rotates an angle a about a vector v=(vx,vy,vz):
(cos(a/2) , vx sin(a/2) , vy sin(a/2) , vz sin (a/2) )
So to rotate 60 degrees about the x axis, you would use the quaternion:
(0.866,0.5,0,0)
The wikipedia pages on quaternion and quaternion rotations gives some good
info:
http://en.wikipedia.org/wiki/Quaternion
http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation
Post a reply to this message
|
|